package br.com.cicero.notasfiscais.infra;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JPAUtil {
	
	private static EntityManagerFactory entityManagerFactory = 
		Persistence.createEntityManagerFactory("notas");
	
	@Produces
	@RequestScoped
	public EntityManager getEntityManager() {
		
		return this.entityManagerFactory.createEntityManager();
		
	}
	
	public void close(@Disposes EntityManager em) {
		
		em.close();
		
	}

}
